package com.hanter.demo.taskstack;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import static android.R.attr.start;
import static android.icu.lang.UCharacter.GraphemeClusterBreak.L;

public class AActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_a);
    }

    @Override
    protected void onResume() {
        super.onResume();

        boolean fromHistory = (getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0;

        if (fromHistory)
            Toast.makeText(this, "从History启动", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent(this, BActivity.class);
        startActivityForResult(intent, 1);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);


//        Toast.makeText(this, "resultCode -> " + resultCode, Toast.LENGTH_SHORT).show();

        if (data != null) {
            String extra = data.getStringExtra("test");

            Toast.makeText(this, "resultData -> " + extra, Toast.LENGTH_SHORT).show();
        }

    }
}
